package com.design3.graduatethesissys.controller; 
/** 
* @author 作者 罗穆健: 
* @version 创建时间：2020年1月11日 下午4:52:52 
* 类说明 
*/

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.design3.graduatethesissys.common.utils.GetUserName;
import com.design3.graduatethesissys.common.utils.ResetPasswordUtils;
import com.design3.graduatethesissys.domain.Student;
import com.design3.graduatethesissys.service.impl.StudentServiceImpl;

@RequestMapping("/Student")
@Controller
public class StudentController {
	
	@Autowired
	StudentServiceImpl studentService;

	
	/**
	 * 
	 * @param student
	 * @return 成功返回success,失败返回false
	 */
	@RequestMapping("/updateStudent")
	@ResponseBody
	public String updateStudent(Student student) {
		student.setStu_id(GetUserName.getUserName());
		return studentService.updateStudent(student);
	}
	
	@RequestMapping("/getStudent")
	@ResponseBody
	public Student getStudent() {
		return studentService.getStudent();
	}
	
	@RequestMapping("/updatePassword")
	@ResponseBody
	public String updatePassword(@RequestParam("stu_old_password")String oldPassword,
			@RequestParam("stu_new_password")String newPassword,
			@RequestParam("stu_new_checkpassword")String confirmPassword) {
		System.out.println(oldPassword);
		System.out.println(newPassword);
		System.out.println(confirmPassword);
		return ResetPasswordUtils.resetPassword(oldPassword, newPassword, confirmPassword);
	}
}
 